package pteam;
import simulator.Actor;
import simulator.RangeFinder;
import simulator.Robot;
import simulator.Sensor;
import simulator.BumpSensor;

public class TurtleActor implements Actor {
  int step = 0;
  int nsteps = 3;
  boolean trouble=false;
  boolean ahead=false;
  public TurtleActor() {
  
  }
  public String getMaze() {
    return "Example";
  }
  public void act(Robot r) {
    if(step%2==0)
      r.getServo().rotate(10.0);
    step++;
    if(step>12)
      step=0;
    //r.goForward();
    //r.waitDistance(5);
  }
  
  public void updateSensors(Sensor[] sensors) {
     //System.out.println("updating sensor");
     if(sensors[1].getState()[0] != ((RangeFinder) (sensors[1])).getRange() ){
	   System.out.println("Found wall at range " +sensors[1].getState()[0]);
	   if(sensors[1].getState()[0]<15)
	     ahead=true;
     }if(sensors[1].getState()[0] == BumpSensor.PRESSED){
	   trouble=true;
	   System.out.println("hit!");
     }

    /*for(int i=0; i<sensors.length; i++) {
      double[] data = sensors[i].getState();
      String name = sensors[i].getName();
      // what that data means is up to the specific sensors subclass.
      // this is ugly... we probably should have a wrapper on sensors data
      // that relates it to special coordinates (or something!!). an array of 
      // doubles is completely useless
    }*/
  }
}